<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<form #applicationScopeForm="ngForm" style="padding: 15px; border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 4px;">
  <div fxLayout="row" fxLayoutGap="5px">
    <mat-form-field appearance="outline" floatLabel="always" fxFlex="20">
      <mat-select placeholder="Scope" name="key" [(ngModel)]="scope.key" [formControl]="selectScopes">
        <mat-select-trigger>{{selectScopes.value ? selectScopes.value : ''}}</mat-select-trigger>
        <mat-option *ngFor="let scope of scopes" [value]="scope.key">
          <mat-icon style="vertical-align:middle;">donut_large</mat-icon>
          <span>{{ scope.key }}</span> | <small>{{scope.name}}</small>
        </mat-option>
      </mat-select>
    </mat-form-field>
    <mat-form-field appearance="outline" floatLabel="always" fxFlex="26">
      <input matInput type="number" placeholder="Duration time" name="expiresIn" min="0" [min]="0" [(ngModel)]="scope.expiresIn">
      <mat-hint>Optional. User consent duration.</mat-hint>
    </mat-form-field>
    <mat-form-field appearance="outline" floatLabel="always" fxFlex="38">
      <mat-select placeholder="Unit time" name="unitTime" [(ngModel)]="scope.unitTime">
        <mat-option value="seconds">SECONDS</mat-option>
        <mat-option value="minutes">MINUTES</mat-option>
        <mat-option value="hours">HOURS</mat-option>
        <mat-option value="days">DAYS</mat-option>
        <mat-option value="weeks">WEEKS</mat-option>
        <mat-option value="months">MONTHS</mat-option>
        <mat-option value="years">YEARS</mat-option>
      </mat-select>
      <mat-hint>Optional. Unit time for the user consent duration.</mat-hint>
    </mat-form-field>
    <div>
      <button style="margin-top: 7px;" mat-stroked-button [disabled]="formIsInvalid()" (click)="addScope()">+ ADD</button>
    </div>
  </div>
</form>
